package org.alex.nettychat.netty.custom.console;

import io.netty.channel.Channel;
import org.alex.nettychat.netty.custom.protocol.MessageRequestPacket;

import java.util.Scanner;

/**
 * @author : alex
 */
public class SendToUser implements ConsoleCommand{
    @Override
    public void exec(Scanner scanner, Channel channel) {
        System.out.println("请输入接受人id:");
        Integer userId = scanner.nextInt();

        System.out.println("请输入发送信息:");
        String message = scanner.nextLine();

        MessageRequestPacket messageRequestPacket = new MessageRequestPacket();

        messageRequestPacket.setToUserId(userId);
        messageRequestPacket.setMessage(message);
        channel.writeAndFlush(messageRequestPacket);
    }
}
